﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RATSharp.Validator
{
    /// <summary>
    /// Validator for console input which accepts only enums from generic param
    /// 
    /// </summary>
    /// <typeparam name="T">enum which should be validated</typeparam>
    public class StringInputEnumValidator<T> : IInputValidator<T> where T : struct, IConvertible
    {

        ///<inheritdoc />
        public bool validate(string input, out T output)
        {
            return Enum.TryParse<T>(input, out output);
        }
    }
}
